<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>构建四则运算的抽象语法树AST</title>
</head>
<body>
  
</body>
<script>
  let regexp=/([0-9\.]+)|([ \t]+)|([\r\n]+)|(\*)|(\/)|(\-)|(\+)/g
  let distionary=["Number","Whitespace","LineTerminator","*","/","-","+"]

  function tokenSize(source){
    var result=null;
    while(true){
     result=regexp.exec(source);
      if(!result) break;
      for(var i=1;i<distionary.length;i++){
        if(result[i])
        console.log(distionary[i-1]);
      }
      console.log(result)
    }
  }
  tokenSize('1024 + 10 * 25')
</script>
</html>